draw_triangles_normals:
    push     ebp
    mov      ebp,esp
    sub      esp,90
    and      ebp,-16

   .xress     equ [ebp-16]
   .f03       equ [ebp-32]
   .f30       equ [ebp-48]
   .scr       equ [ebp-52]                     ; .scr
   .zbuff     equ [ebp-56]                     ; .zbu
   .tex_ptr   equ dword[ebp-60]                ; .linetexptr / col
   .width     equ [ebp-64]                     ; .width

    cld
    xorps      xmm6,xmm6
    movd      xmm7,[xres_vard]
    punpcklwd xmm7,xmm6
    movaps    .xress,xmm7
    movd      .width,xmm7
    mov       .tex_ptr,0x000000ff
    mov       esi,[screen_ptr]
    mov       ebx,30.0
    mov       edx,0.33333333
    mov       .scr,esi
    movd      xmm2,ebx
    movd      xmm3,edx
    shufps    xmm2,xmm2,0
    shufps    xmm3,xmm3,0
    movaps    .f03,xmm3
    movaps    .f30,xmm2
    mov       .col,0x0000ffff
    cmp       eax,'vert'
    je       .vert

    mov     ecx,[triangles_count_var]
    mov     esi,[triangles_ptr]
    mov     edi,[triangles_normals_rotated_ptr]
    mov     edx,[points_rotated_ptr]
  .nt:
    push    edx
    push    ecx
    push    edi
    lodsd
    xchg    ebx,eax
    lodsd
    xchg    ecx,eax
    lodsd
    imul    eax,12
    imul    ebx,12
    imul    ecx,12
    movups  xmm0,[eax+edx]
    movups  xmm1,[ebx+edx]
    movups  xmm2,[ecx+edx]

    push    esi
    addps   xmm0,xmm1
    addps   xmm0,xmm2
    mulps   xmm0,.f03
    movups   xmm1,[edi]
    mulps    xmm1,.f30
    addps    xmm1,xmm0
    movlhps  xmm0,xmm1
    cvtps2dq xmm0,xmm0

    sub        esp,16
    movups     [esp],xmm0
    pop        eax ebx ecx edx
    xorps       xmm6,xmm6
    movaps     xmm5,.width
    movlps       xmm7,.xress
    mov        edi,plain_horizontal
    call       line_grd_tex


    pop     esi
    pop     edi
    pop     ecx
    pop     edx
    add     edi,12
    loop    .nt  ;.next

    jmp     .end

  .vert:
    mov     ecx,[points_count_var]
    mov     edi,[points_normals_rotated_ptr]
    mov     esi,[points_rotated_ptr]

  .nv:
    push     esi
    push     edi
    push     ecx

    movups   xmm0,[edi] ; nr
    movups   xmm1,[esi] ; pts
    mulps    xmm0,.f30
    addps    xmm0,xmm1
    movhps   xmm0,[esi]
    cvtps2dq xmm0,xmm0
    sub      esp,16
    movups   [esp],xmm0
    pop      eax ebx ecx edx

    xorps       xmm6,xmm6
    movaps     xmm5,.width
    movlps       xmm7,.xress
    mov        edi,plain_horizontal
    call       line_grd_tex

    pop     ecx
    pop     edi
    pop     esi
    add     edi,12
    add     esi,12
    loop    .nv

   .end:


    add     esp,90
    pop     ebp
ret
